package main

import (
	"github.com/kingparks/copilot-vip/auth"
	"github.com/kingparks/copilot-vip/tui"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	productSelected := tui.Run()
	startServer(productSelected)
}

func startServer(productSelected string) {
	tui.Sigs = make(chan os.Signal, 1)
	signal.Notify(tui.Sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL)
	go func() {
		<-tui.Sigs
		auth.UnSetClient(productSelected)
		os.Exit(0)
	}()

	auth.Run(productSelected)
}
